#include <stdio.h>
#include <stdlib.h>

#define SHM_QUEUE_IMPLEMENTATION
#include "shm_queue.h"

int main() {
  shm_queue_t wqueue;
  shm_queue_options_t options;
  options.elem_count = 128;
  options.elem_size = 1024;
  options.mode = SHM_QUEUE_MODE_WRITE;
  options.name = "test";
  int rslt = shm_queue_open(&wqueue, &options);

  printf("shm_queue_open ret:%d\n", rslt);

  while (1)  {
    static const char str[] = "123456789012345678901234567890";
    int rslt = shm_queue_write(&wqueue, (void*)str, rand() % sizeof(str));
    if (rslt < 0) {
      printf("shm_queue_write  error ret:%d\n", rslt);
    }
    usleep(100000);
  }

  printf("finish\n");
  shm_queue_close(&wqueue);
  return 0;
}
